package com.sddongyun.config;

import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.annotation.Configuration;

@Configuration
public class SpringContext implements ApplicationContextAware {
    private static ApplicationContext applicationContext;
    public static ApplicationContext getApplicationContext() {
        return SpringContext.applicationContext;
    }
    @Override
    public void setApplicationContext(ApplicationContext applicationContext){
        SpringContext.applicationContext = applicationContext;
    }
    public static Object getBean(String beanName) {
        return getApplicationContext().getBean(beanName);
    }
    public static <T> T getBean(Class<T> cls) {
        return getApplicationContext().getBean(cls);
    }
}